package edu.cmu.cs211.bacon.tests;
import static org.junit.Assert.*;


import org.junit.Test;

import edu.cmu.cs211.bacon.util.Edge;
import edu.cmu.cs211.bacon.util.GeneralGraph;
import edu.cmu.cs211.bacon.util.Dijkstra;
public class DijkstraTest {
	
	@Test (expected = IllegalArgumentException.class)
	public void testException()
	{
		GeneralGraph<String, Edge<String>> g = new GeneralGraph<String, Edge<String>>();
		g.addVertex("s");
		g.addVertex("a");
		g.addEdge(new Edge<String>("s", "a", -5));
		Dijkstra a = new Dijkstra();
		a.shortestPath(g, "s", "a");
	}
	
	@Test
	public void simple()
	{
		GeneralGraph<String, Edge<String>> g = new GeneralGraph<String, Edge<String>>();
		g.addVertex("s");
		g.addVertex("a");
		g.addVertex("b");
		g.addVertex("c");
		g.addVertex("d");
		g.addVertex("e");
		g.addVertex("f");
		g.addVertex("g");
		
		g.addEdge(new Edge<String>("s", "c", 4));
		g.addEdge(new Edge<String>("s", "b", 2));
		g.addEdge(new Edge<String>("s", "a", 5));
		g.addEdge(new Edge<String>("c", "b", 1));
		g.addEdge(new Edge<String>("b", "d", 1));
		g.addEdge(new Edge<String>("d", "a", 1));
		g.addEdge(new Edge<String>("b", "e", 4));
		g.addEdge(new Edge<String>("f", "e", 2));
		g.addEdge(new Edge<String>("c", "f", 2));
		
		Dijkstra a = new Dijkstra();
		
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "a").size(),3);
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "b").size(),1);
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "c").size(),1);
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "d").size(),2);
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "e").size(),2);
		assertEquals("the size of vertices size",a.shortestPath(g, "s", "f").size(),2);
	}
}
